/**
 * lilang
 * StringliptUtil.java
 * 2013-9-12下午3:40:59
 */
package com.cq.oa.utils;

import java.util.ArrayList;
import java.util.List;

/**
 * @author lilang
 *
 */
public class StringliptUtil {
	
	/**
	 * 逗号切分
	 * @param ids
	 * @return
	 * lilang 
	 * 2013-9-12下午3:41:45
	 */
	public static String[] split(String ids){
		return ids.split(",");
	}
	
	/**
	 *  string 转 long
	 * @param ids
	 * @return
	 * lilang 
	 * 2013-9-12下午3:43:57
	 */
	public static List<Long> string2Long(String[] ids){
		List<Long> list = new ArrayList<Long>();
		for(String id:ids){
			list.add(Long.valueOf(id));
		}
		return list;
	}
	
	/**
	 * string 拆分成LIST  LONG 
	 * @author: lilang
	 * @param value
	 * @return
	 */
	public static final List<Long> splitString(String value){
		List<Long> sids = new ArrayList<Long>();
		if (value != null && !value.trim().equals("")) {
			String[] lists = value.split(",");
			for (String i : lists) {
				sids.add(Long.valueOf(i));
			}
		}
		return sids;
	}
	/**
	 * string 拆分成LIST  String 
	 * @author: lilang
	 * @param value
	 * @return
	 */
	public static final List<String> splitMail(String value){
		List<String> sids = new ArrayList<String>();
		if (value != null && !value.trim().equals("")) {
			String[] lists = value.split(",");
			for (String i : lists) {
				sids.add(i);
			}
		}
		return sids;
	}
	/**
	 * 集合转数组
	 * @param longs
	 * @return
	 */
	public static final Long[] listToArray(List<Long> longs){
		Long[] sids = new Long[longs.size()];
		for(int i=0;i<longs.size();i++){
			sids[i]=longs.get(i);
		}
		return sids;
	}

	
	public static String listToString(List<String> email){
		StringBuffer sb = new StringBuffer();
		for(String e:email){
			sb.append(",").append("'"+e+"'");
		}
		if(sb.length()>0){
			String result = sb.toString().substring(1);
			return result;
		}else{
			return "";
		}
	}
	
	
}
